package vis.manage.demo;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vis.core.domain.sys.SRS;

@RestController
@RequestMapping("/demo/form")
public class DemoFormController {

    @RequestMapping("/index")
    public Object index(String a) {
        return "index ---- " + a;
    }

    @RequestMapping("/login")
    public Object login(String a) {
        StpUtil.login(10001);
        return "登录成功";
    }

    @RequestMapping("/logout")
    public Object logout(String a) {
        StpUtil.logout(10001);
        return "已退出登录状态";
    }

    @RequestMapping("/isLogin")
    public Object isLogin(String a) {
        boolean login = StpUtil.isLogin();
        return "当前登录状态===>" + login;
    }

    @SaCheckLogin
    @RequestMapping("/auth1")
    public Object auth1(String a) {
        return "您具备访问权限";
    }

    @SaCheckRole("d1")
    @SaCheckPermission("dd:d1")
    @RequestMapping("/dd/d11")
    public Object d11(String a) {
        return SRS.bySuccess();
    }

    @SaCheckRole("d2")
    @SaCheckPermission("dd:d2")
    @RequestMapping("/dd/d12")
    public Object d12(String a) {
        return SRS.bySuccess();
    }

    @SaCheckRole("d2")
    @RequestMapping("/dd/d21")
    public Object d21(String a) {
        return SRS.bySuccess();
    }

    @SaCheckRole("d2")
    @RequestMapping("/dd/d22")
    public Object d22(String a) {
        return SRS.bySuccess();
    }

    @RequestMapping("/dd/d31")
    public Object d31(String a) {
        return SRS.bySuccess();
    }

    @RequestMapping("/dd/d32")
    public Object d32(String a) {
        return SRS.bySuccess();
    }

}
